CC = gcc
CFLAGS = -Iinc -Wall -Wextra
DEBUG_FLAGS = -g

SRC_DIR = src
OBJ_DIR = obj
INC_DIR = inc

SRC_FILES = $(shell find $(SRC_DIR) -name '*.c')
OBJ_FILES = $(SRC_FILES:$(SRC_DIR)/%.c=$(OBJ_DIR)/%.o)

TARGET = joky

ifeq ($(DEBUG), 1)
    CFLAGS += $(DEBUG_FLAGS)
endif

all: $(TARGET)

$(TARGET): $(OBJ_FILES)
	$(CC) -o $@ $^ -lncurses

$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
	@mkdir -p $(dir $@) 
	$(CC) $(CFLAGS) -c $< -o $@ 

clean:
	rm -rf $(OBJ_DIR) $(TARGET)

.PHONY: all clean
